package main

import "fmt"

type Human struct {
	name string
	sex  string
}

func (this *Human) Eat() {
	fmt.Println("Human.Eat()...")
}

func (this *Human) Walk() {
	fmt.Println("Human.Walk()...")
}

//=================

type SuperMan struct {
	Human //SuperMan类继承了Human类的方法
	//Book
	//Hero
	level int
}

//重定义父类的方法Eat()
func (this *SuperMan) Eat() {
	fmt.Println("SuperMan.Eat()...")
}

//子类的新方法
func (this *SuperMan) Fly() {
	fmt.Println("SuperMan.Fly()...")
}

func (this *SuperMan) Print() {
	fmt.Println("name = ", this.name)
	fmt.Println("sex = ", this.sex)
	fmt.Println("level = ", this.level)
}

func main() {
	h := Human{"zhangsan", "female"}
	h.Eat()  //Human.Eat()...
	h.Walk() //Human.Walk()...

	s := SuperMan{
		Human: Human{"lis", "female"},
		level: 0,
	}
	s.Walk()  //Human.Walk()...
	s.Eat()   //SuperMan.Eat()...
	s.Fly()   //SuperMan.Fly()...
	s.Print() //SuperMan.Print()...

}
